package Javatest;

import java.util.List;

public class Book {
    private String name;
    private String publicaionDate;
    private String publisher;
    private double price;
    private String[] authors;

    public Book() {
        name = "未知";
        publicaionDate = "未知";
        publisher = "未知";
        price = 0.0;
        authors = new String[0];
    }

    public Book(String name) {
        this.name = name;
        publicaionDate = "未知";
        publisher = "未知";
        price = 0.0;
        authors = new String[0];
    }

    public Book(String name, String publicationDate, String publisher, double price, String[] authors) {
        this.name = name;
        this.publicaionDate = publicationDate;
        this.publisher = publisher;
        this.price = 30.0;
        this.authors = new String[]{"zhangsan", "lisi"};
    }

    public void SetPublisher(String publisher) {
        this.publisher = publisher;
    }

    public String GetPublisher(String publisher) {
        return publisher;
    }

    public void SetPrice(double price) {
        this.price = 30.0;
    }

    public double GetPrice(double price) {
        return price;
    }

    public void printAuthors() {
        for (String author : authors) {
            System.out.println(author);
        }
    }

    public void compose(){
        System.out.println("书默认排版");
    }


    public static class JavaBook extends Book {
        private String jdkVersion;
        private String[] javalist;
        private String isbn;

        public JavaBook(String name, String jakVersion, List<String> javaList, String isbn) {
            super(name, "unknown", "unknown", 0.0, new String[0]);
            this.jdkVersion = jakVersion;
            this.javalist = javalist;
            this.isbn = isbn;
        }

        public JavaBook() {
            jdkVersion = "unknown";
            javalist = new String[0];
            isbn = "unknown";

        }

        public void setJdkVersion(String jdkVersion) {
            this.jdkVersion = jdkVersion;
        }

        public String getJdkVersion() {
            return jdkVersion;
        }


        public boolean equals(Object obj) {
            if (obj instanceof JavaBook) {
                return this.isbn.equals(((JavaBook) obj).isbn);
            }
            return false;
        }

        @Override
        public void compose(){
            System.out.println("计算机类书排版：考虑代码布局");
        }

        public void read(Book book){
            if(book instanceof JavaBook){
                System.out.println("实际参数是 Javabook 对象");
            }else if(book instanceof MathBook){
                System.out.println("实际参数是 Mathbook 对象");
            }else{
                System.out.println("是其他书");
            }
        }

    }


    public static class MathBook extends Book {

        public MathBook() {

        }

        @Override
        public void compose(){
            System.out.println("数学类书排版：考虑公式布局");
        }

    }


    public static class Main {
        public static void main(String[] args) {
            Book book = new Book();
            JavaBook javaBook = new JavaBook();
            MathBook mathBook = new MathBook();

            Book b1;
            b1 = book;
            b1.compose();
            b1.printAuthors();

            Book b2;
            b2 = javaBook;
            b2.compose();

            Book b3;
            b3 = mathBook;
            b3.compose();

        }
    }






    public static class Course {
        protected String courseNumber;
        protected String lecturerName;
        protected int classHours;
        protected String textbook;
        protected String[] auxiliaryTextbooks;

        // 构造方法 1：有 2 个参数，课程编号和主讲教师
        public Course(String courseNumber, String lecturerName) {
            this.courseNumber = courseNumber;
            this.lecturerName = lecturerName;
        }

        // 构造方法 2：所有参数
        public Course(String courseNumber, String lecturerName, int classHours, String textbook, String[] auxiliaryTextbooks) {
            this.courseNumber = courseNumber;
            this.lecturerName = lecturerName;
            this.classHours = classHours;
            this.textbook = textbook;
            this.auxiliaryTextbooks = auxiliaryTextbooks;
        }
    }

    public static class JavaCourse extends Course {
        private String jdkVersion;
        private String[] ideList;

        public JavaCourse(String courseNumber, String lecturerName, int classHours, String textbook, String[] auxiliaryTextbooks, String jdkVersion, String[] ideList) {
            super(courseNumber, lecturerName, classHours, textbook, auxiliaryTextbooks);
            this.jdkVersion = jdkVersion;
            this.ideList = ideList;
        }

        @Override
        public String toString() {
            return "课程编号 = " + courseNumber + ", 主讲教师 = " + super.lecturerName + ", 课时数 = " + classHours + ", 采用了 JDK 版本 = " + jdkVersion;
        }

        public static void main(String[] args) {
            JavaCourse javaCourse = new JavaCourse("001", "张老师", 32, "Java 基础教程", new String[]{"Java 进阶教程"}, "1.8", new String[]{"Eclipse", "IntelliJ IDEA"});
            System.out.println(javaCourse.toString());
        }
    }


}
